<template>
  <div class="content">
    <dc-header :icon="'icon-header-back'" :title="'门店营业数据'"></dc-header>
    <div class="head-top">
      <dc-date @getTabBarDatep="getDate" :startTime="this.curDate.startTime" :startDateType="this.curDate.type"></dc-date>
      <dc-rank ref="saleRank" :titles="rankTitles" :rankKey="rankKey"
               :param="param" url="getshopAnalysisDetail"></dc-rank>
    </div>
  </div>
</template>
<script>
  import header from '@/common/plugins/header';
  import date from '@/common/plugins/datetabbar/all';
  import {mapMutations, mapGetters} from 'vuex';
  import rankList from '@/common/plugins/rankList';
  export default {
    data () {
      return {
        param: {},
        shopLines: [],
        rankKey: ['storeName', 'busiTotal', 'incomeTotal', 'bsCount'],
        rankTitles: [
          {name: '门店', isRank: false},
          {name: '营业额', isRank: false},
          {name: '实际收入', isRank: false},
          {name: '客单数', isRank: false}
        ]
      };
    },
    created () {
      this.param.size = 0;
      this.param.timeFlag = this.curDate.type;  //时间范围标识，1-日；2-周；3-月；4-年
      this.param.beginTime = this.curDate.startTime;
      this.param.endTime = this.curDate.endTime;
    },
    activated () {
      this.param.size = 0;
      this.param.timeFlag = this.curDate.type;  //时间范围标识，1-日；2-周；3-月；4-年
      this.param.beginTime = this.curDate.startTime;
      this.param.endTime = this.curDate.endTime;
    },
    computed: {
      ...mapGetters(['curDate'])
    },
    components: {
      'dc-header': header,
      'dc-date': date,
      'dc-rank': rankList
    },
    methods: {
      ...mapMutations({saveDate: 'SAVEDATE'}),
      getDate (date) {
        this.param.sortFlag = 0;
        this.param.timeFlag = date.type;
        this.param.beginTime = date.startTime;
        this.param.endTime = date.endTime;
        this.saveDate(date);
        this.$refs.saleRank.changeList();
      }
    }
  };
</script>
<style lang="scss" scoped>
</style>
